package com.googlecode.continuity.plugin.svnbrowser.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.googlecode.continuity.core.client.CoreGWT;
import com.googlecode.continuity.core.client.rpc.RPCCreationCallback;

/**
 * Initializes the readSVN RPC. We can't do this in the SVN browser since that class uses the RPC in it's constructor.
 *
 * @author Peter Schmitt <aragos@aragos.de>
 */
public class SVNBrowserInit implements EntryPoint {
  public void onModuleLoad() {
    CoreGWT.registerRPC("ReadSVNRPCAsync", new RPCCreationCallback() {
      public Object createRPC() {
        ReadSVNRPCAsync svnRpc = (ReadSVNRPCAsync) GWT.create(ReadSVNRPC.class);
        ServiceDefTarget endpoint = (ServiceDefTarget) svnRpc;
        String moduleRelativeURL = CoreGWT.getWebappRoot() + "readsvn.rpc";
        endpoint.setServiceEntryPoint(moduleRelativeURL);
        return svnRpc;
      }
    });
  }
}
